<?php
/// 函数名称：dcomment_g_title
/// 函数作用：帅哥认证标识
/// 函数作者: DH
/// 作者地址: http://dhblog.org/ 
function comment_g_title($email = '')
{
	if(empty($email))return;
	$handsome = get_option('dh_comment_g_title');
	if(!$handsome)
	{
		$handsome = get_comment_g_title();
	}
	$adminEmail = get_option('admin_email');
	if($email==$adminEmail)
	echo " <div class='admin' title='博主'>博主</div>";
	elseif(in_array($email,$handsome))
	echo " <div class='handsome' title='帅哥'>帅哥</div>";
}

function get_comment_g_title()
{
	global $wpdb;
	$adminEmail = get_option('admin_email');
	$request="SELECT comment_author_email FROM $wpdb->comments WHERE comment_author_email != '$adminEmail' AND comment_approved='1' GROUP BY comment_author_email having count(*) > 10";
	$handsomes=$wpdb->get_results($request);
	$handsome = array();
	foreach ($handsomes as $handsomei)
	{
		array_push($handsome,$handsomei->comment_author_email);
	}		
	update_option('dh_comment_g_title', $handsome);
	return $handsome;
}

add_action('comment_post', 'get_comment_g_title');
?>